package com.qf.anno.mapper;

import com.qf.anno.domain.Account;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface AccountMapper {

    @Insert("insert into account values (null,#{name},#{money})")
    int insert(Account account);

    @Delete("delete from account where id=#{id}")
    int delete(Integer id);

    @Update("update account set name=#{name},money=#{money} where id=#{id}")
    int update(Account account);

    @Select("select * from account")
    List<Account> findAll();

    @Select("select * from account where id=#{id}")
    Account findById(Integer id);

    @Select("select * from account where name=#{name}")
    Account findByName(String name);

    @Update("update account set money=money+#{money} where name=#{name}")
    void updateMoneyByName(@Param("money") Double money, @Param("name") String name);
}
